package me.goldze.mvvmhabit.utils;

public class MyStringUtils {
    public static int inverted(String paramString1, String paramString2, int paramInt)
    {
        if ((paramInt < 0) || (paramInt > paramString1.length()) || ("".equals(paramString1)) || ("".equals(paramString2)))
            return -1;
        return paramString1.lastIndexOf(paramString2, paramInt);
    }

    public static String[] 分割文本(String paramString1, String paramString2)
    {
        if (("".equals(paramString2)) || ("".equals(paramString1)))
            return new String[0];
        if (paramString2.equals("\n"))
            paramString1 = replaceAll(paramString1, "\r", "");
        if (getStringRight(paramString1, length(paramString2)).equals(paramString2))
            return getString(paramString2 + paramString1, paramString2, paramString2);
        return getString(paramString2 + paramString1 + paramString2, paramString2, paramString2);
    }

    public static String trimAll(String paramString)
    {
        char[] arrayOfChar = paramString.toCharArray();
        int i = 0;
        int j = -1 + arrayOfChar.length;
        while ((j > 0) && (arrayOfChar[j] == ' '))
        {
            j--;
            i++;
        }
        String str = paramString;
        if (i > 0)
            str = new String(arrayOfChar, 0, arrayOfChar.length - i);
        return str;
    }

    public static String trimEnd(String paramString)
    {
        return paramString.trim();
    }

    public static String trimStart(String paramString)
    {
        char[] arrayOfChar = paramString.toCharArray();
        int i = 0;
        int j = 0;
        while ((j < arrayOfChar.length) && (arrayOfChar[j] == ' '))
        {
            j++;
            i++;
        }
        String str = paramString;
        if (i > 0)
            str = new String(arrayOfChar, i, arrayOfChar.length - i);
        return str;
    }

    public static String toUpperCase(String paramString)
    {
        return paramString.toUpperCase();
    }

    public static String toLowerCase(String paramString)
    {
        return paramString.toLowerCase();
    }

    public static String[] getString(String paramString1, String paramString2, String paramString3)
    {
        if (("".equals(paramString1)) || ("".equals(paramString2)) || ("".equals(paramString3)))
            return new String[0];
        return RegularUtils.paramMatcher(paramString1, "(?<=\\Q" + paramString2 + "\\E).*?(?=\\Q" + paramString3 + "\\E)");
    }

    public static String getString2(String paramString1, String paramString2, String paramString3)
    {
        String[] arrayOfString = getString(paramString1, paramString2, paramString3);
        if (arrayOfString.length > 0)
            return arrayOfString[0];
        return "";
    }

    public static String getString3(String paramString, int paramInt1, int paramInt2)
    {
        if (("".equals(paramString)) || (paramInt1 < 0) || (paramInt2 <= 0) || (paramInt1 > paramString.length()))
            return "";
        int i = paramInt1 + paramInt2;
        if (i > paramString.length())
            i = paramString.length();
        return paramString.substring(paramInt1, i);
    }

    public static String getStringRight(String paramString, int paramInt)
    {
        if (("".equals(paramString)) || (paramInt <= 0))
            paramString = "";
        while (paramInt > paramString.length())
            return paramString;
        return paramString.substring(paramString.length() - paramInt, paramString.length());
    }

    public static String getStringLeft(String paramString, int paramInt)
    {
        if (("".equals(paramString)) || (paramInt <= 0))
            paramString = "";
        while (paramInt > paramString.length())
            return paramString;
        return paramString.substring(0, paramInt);
    }

    public static int length(String paramString)
    {
        return paramString.length();
    }

    public static int length2(String paramString)
    {
        return paramString.getBytes().length;
    }

    public static String replaceAll(String paramString1, String paramString2, String paramString3)
    {
        if (("".equals(paramString2)) || ("".equals(paramString1)))
            return "";
        return paramString1.replaceAll("\\Q" + paramString2 + "\\E", paramString3);
    }

    public static String replaceAll2(String paramString1, int paramInt1, int paramInt2, String paramString2)
    {
        if (("".equals(paramString1)) || (paramInt1 < 0) || (paramInt1 > paramString1.length()) || (paramInt2 < paramInt1) || (paramInt2 > paramString1.length()))
            return "";
        return paramString1.substring(0, paramInt1) + paramString2 + paramString1.substring(paramInt2 + 1);
    }

    public static int findText(String paramString1, String paramString2, int paramInt)
    {
        if ((paramInt < 0) || (paramInt > paramString1.length()) || ("".equals(paramString1)) || ("".equals(paramString2)))
            return -1;
        return paramString1.indexOf(paramString2, paramInt);
    }

    public static int compareTo(String paramString1, String paramString2)
    {
        return paramString1.compareTo(paramString2);
    }

    public static String reverse(String paramString)
    {
        return new StringBuffer(paramString).reverse().toString();
    }
}
